package com.cj.demo6.service;

import com.cj.demo6.mapper.UserMapper;
import com.cj.demo6.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
@Service
public class UserService {
    @Autowired
    UserMapper userMapper;
    public List<User> selectAll(){
        return userMapper.selectList(null);
    }
    public int insert(User user){
        return userMapper.insert(user);
    }
    public int update(User user){
        return userMapper.updateById(user);
    }
    public int delete(int uId){
        return userMapper.deleteById(uId);
    }
    public int deletes(int[] uIds){
        return userMapper.deleteBatchIds(Arrays.asList(uIds));
    }
    public List<User> selectMapper(User user){
        HashMap<String,Object> map = new HashMap<String, Object>();
        map.put("u_name",user.getUName());
        map.put("u_sex",user.getUSex());
        map.put("u_age",user.getUAge());
        return userMapper.selectByMap(map);
    }
}
